package com.juli.v2xdemo.presenter;

import android.content.Context;
import android.util.Log;

import com.cz.basetool.ui_work.thread.MainHandler;

import com.example.tcpmaster.TcpConfig;
import com.juli.v2xdemo.tcp.controller.TcpController;
import com.juli.v2xdemo.tcp.tcp_impl.TcpActionCallBack;

/**
 * Created by XinYi on 2019/5/21.
 */

public class TcpPresenter {
    private Context context;
    private TcpActionCallBack tcpActionCallBack;
    private TcpUICallBackImpl tcpUICallBack;

    public TcpPresenter(Context context, TcpActionCallBack tcpActionCallBack, TcpUICallBackImpl tcpUICallBack) {
        this.context = context;
        this.tcpActionCallBack = tcpActionCallBack;
        this.tcpUICallBack = tcpUICallBack;
    }

    public void init(){
       TcpConfig.getInstance().setIp("192.168.50.3");
//                TcpConfig.getInstance().setIp("172.20.10.4");

        TcpConfig.getInstance().setPort(6000);
        MainHandler.getInstance().postDelayed(new Runnable() {
            @Override
            public void run() {
                 connect();
                 ///撒大声地
            }
        },1000);
    }

    public void connect(){
        TcpController.getInstance().connect(context,tcpActionCallBack,tcpUICallBack,true);
    }
    public void  send(){
        Log.e("99999999999999999", "发送");
        TcpController.getInstance().sendMsg("55aa000280a0ae72");
    }

    public void disConnect(){
        TcpController.getInstance().disConnect();
    }
}
